//package com.oa.core.handler;
//
//import com.fasterxml.jackson.core.JsonGenerator;
//import com.fasterxml.jackson.databind.SerializerProvider;
//import com.fasterxml.jackson.databind.ser.std.StdSerializer;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//import java.util.Map;
//
///**
// * Created on 2018/5/24 0024.
// *
// * @author zlf
// * @email i@merryyou.cn
// * @since 1.0
// */
//public class CustomOauthExceptionSerializer extends StdSerializer<CustomOauthException> {
//    public CustomOauthExceptionSerializer() {
//        super(CustomOauthException.class);
//    }
//
//    @Override
//    public void serialize(CustomOauthException value, JsonGenerator gen, SerializerProvider provider) throws IOException {
//        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
//
//        gen.writeStartObject();
////        gen.writeStringField("error", String.valueOf(value.getHttpErrorCode()));
//        gen.writeStringField("code", String.valueOf(value.getHttpErrorCode()));
////        gen.writeStringField("message", value.getMessage());
//        gen.writeStringField("message", "用户名或密码错误！");
////        gen.writeStringField("path", request.getServletPath());
////        gen.writeStringField("timestamp", String.valueOf(System.currentTimeMillis()));
//        if (value.getAdditionalInformation()!=null) {
//            for (Map.Entry<String, String> entry : value.getAdditionalInformation().entrySet()) {
//                String key = entry.getKey();
//                String add = entry.getValue();
//                gen.writeStringField(key, add);
//            }
//        }
//        gen.writeEndObject();
//    }
//}
